package vista;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Rectangle;

import java.util.ArrayList;
import java.util.List;


import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.border.Border;
import javax.swing.border.EtchedBorder;
/**
 * this class will let you create a new Player with his Id values for the game
 * @author Jose Luis Garcia && Alvaro Blazquez Checa
 *
 */
public class InputFrame extends JFrame{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JTextField name;
	private JComboBox<String> combo1;
	private JButton button;
	
	/**
	 * this constuctor create a panel to add the user 
	 * @param bounds the size of the panel
	 * @param backGroundIcon the image for the backGround
	 * @param buttonIcon the image for the button
	 */
	public InputFrame(Rectangle bounds,Icon backGroundIcon,Icon buttonIcon) {
		setBounds(bounds);
		setLayout(null);
		setUndecorated(true);
		
		
		JLabel background=new JLabel(backGroundIcon);
		background.setBounds(3,3,294,194);
		background.setVisible(true);
		
		Border outsideBorder = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
		Border insideBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
		
		((JComponent) getContentPane()).setBorder(BorderFactory.createCompoundBorder(outsideBorder, insideBorder));
		
		Font font = new Font( "SketchFlow Print",Font.BOLD,12 );
		
		name = new JTextField();
		name.setSize(160,getHeight()/7);
		name.setLocation(100, 40);
		
		combo1=new JComboBox<String>();
	    combo1.setBounds(100,92,100,25);
	    
	    button = new JButton("ENVIAR");
	    button.setName("ENVIAR");
	    button.setIcon(buttonIcon);
	    button.setFont(font);
	    button.setLayout(null);
	    button.addActionListener(MainGUI.getInstance());
	    button.setBounds(110, 140, 90, 30);
	    JLabel buttonText = new JLabel();
	    buttonText.setText("Enviar");
	    buttonText.setFont(font);
	    buttonText.setForeground(Color.white);
	    buttonText.setLayout(null);
	    buttonText.setBounds(25, 0, 90, 30);

	    button.add(buttonText);
	    
	    
		JLabel nameLabel = new JLabel();
		nameLabel.setFont(font);
		nameLabel.setText("NOMBRE: ");
		nameLabel.setBackground(Color.BLACK);
		nameLabel.setForeground(Color.white);
		nameLabel.setSize(getWidth()/3,getHeight()/4);
		nameLabel.setLocation(30,30);
		nameLabel.setVisible(true);
		
		JLabel colorLabel = new JLabel();
		colorLabel.setFont(font);
		colorLabel.setText("COLOR: ");
		colorLabel.setBackground(Color.BLACK);
		colorLabel.setForeground(Color.white);
		colorLabel.setSize(getWidth()/3,getHeight()/4);
		colorLabel.setLocation(30,80);
		colorLabel.setVisible(true);
		
		add(name);
		add(nameLabel);
		add(colorLabel);
		add(combo1);
		add(button);
		add(background);
		
		setAlwaysOnTop(true);
	}
	/**
	 * this will set a color for the user 
	 * @param colors the color to be selected
	 */
	public void setValues(List<String> colors) {
		
        for(String str : colors) 
        	combo1.addItem(str);
         	
	}
	/**
	 * returns the selected values for color
	 * @return list of color values 
	 */
	public List<String> getValues() {
		
		List<String> values = new ArrayList<String>();
		values.add(name.getText());
		values.add(combo1.getItemAt(combo1.getSelectedIndex()));
		return values;
		
	}
	/**
	 * to paint the image 
	 * @param g
	 */
	public void painComponent(Graphics g) {
		repaint();
	}
	
}
